<?php
include('common.php');

$parent = $_POST['node'];

if ($parent == '-1' || !$parent)
{
	$parent = './';
}

if ($parent && substr($parent,-1) != '/') $parent.='/';
$nodes = array();
$h = opendir(END_ROOT.$parent);
while( ($v = readdir($h)) !== false)
{
	if ($v == '.' || $v == '..' || !is_dir(END_ROOT.$parent.$v)) continue;
	$nodes[] = array(
		'text'=>$v,
		'id'=>$parent.$v.'/'
	);
}
closedir($h);

exit_array($nodes);